import request from "@/utils/request";

enum API {
    // 品牌管理
    BRAND_LIST = "/admin/product/baseTrademark",
    BRAND_QUERY = "/admin/product/baseTrademark/findBaseTrademarkByKeyword",
    BRAND_DELETE = "/admin/product/baseTrademark/remove",
    BRAND_ADD = "/admin/product/baseTrademark/save",
    BRAND_DETAIL = "/admin/product/baseTrademark/get",
    BRAND_EDIT = "/admin/product/baseTrademark/update",

    // 属性管理
    PROPERTY_GET_CATEGORY1 = "/admin/product/getCategory1",
    PROPERTY_GET_CATEGORY2 = "/admin/product/getCategory2",
    PROPERTY_GET_CATEGORY3 = "/admin/product/getCategory3",
    PROPERTY_GETATTRLIST = "/admin/product/attrInfoList",
    PROPERTY_GETATTR_BYID = "/admin/product/getAttrValueList",
    PROPERTY_REMOVEATTR_BYID = "/admin/product/deleteAttr",
    PROPERTY_SAVEATTR = "/admin/product/saveAttrInfo",
}

// 品牌管理
export const getBrandList = (page:number,limit:number) => request.get(`${API.BRAND_LIST+'/'+page+'/'+limit}`);
export const getBrandListByKeyword = (keyword:string) => request.get(`${API.BRAND_QUERY+'/'+keyword}`);
export const deleteBrandById = (id:number) => request.delete(`${API.BRAND_DELETE+'/'+id}`);
export const insertBrand = (brand: unknown) => request.post(API.BRAND_ADD,brand);
export const getBrandById = (id:number) => request.get(`${API.BRAND_DETAIL+'/'+id}`);
export const editBrand = (brand: unknown) => request.put(API.BRAND_EDIT,brand);

// 属性管理
export const getPropertyCategory1 = () => request.get(API.PROPERTY_GET_CATEGORY1);
export const getPropertyCategory2 = (id:number) => request.get(`${API.PROPERTY_GET_CATEGORY2+'/'+id}`);
export const getPropertyCategory3 = (id:number) => request.get(`${API.PROPERTY_GET_CATEGORY3+'/'+id}`);
export const getPropertyAttrList = (id1:number,id2:number,id3:number) => request.get(`${API.PROPERTY_GETATTRLIST+'/'+id1+'/'+id2+'/'+id3}`);
export const getPropertyAttrById = (id:number) => request.get(`${API.PROPERTY_GETATTR_BYID+'/'+id}`);
export const removePropertyAttrById = (id:number) => request.delete(`${API.PROPERTY_REMOVEATTR_BYID+'/'+id}`);
export const saveAttrInfo = (attr: unknown) => request.post(API.PROPERTY_SAVEATTR,attr);

export default {
    // 品牌管理
    getBrandList,
    getBrandListByKeyword,
    deleteBrandById,
    insertBrand,
    getBrandById,
    editBrand,

    // 属性管理
    getPropertyCategory1,
    getPropertyCategory2,
    getPropertyCategory3,
    getPropertyAttrList,
    getPropertyAttrById,
    removePropertyAttrById,
    saveAttrInfo,
}